<include file="Public/head"/>
<script src="{:get_style_cdnurl()}paimai/yunying/js/city.js" type="text/javascript"></script>
<style type="text/css">
    .branch_company, .man_id {
        display: block;
        text-align: center;
        width: 300px;
        background: #fff url("{:get_style_cdnurl()}paimai/yunying/images/sanjiao.jpg") no-repeat scroll 280px 7px;
        border: 1px solid #d2d2d2;
        color: #303030;
        height: 26px;
        line-height: 26px;
    }
</style>
</head>
<include file="Public/common_header"/>
<div class="mian">
    <include file="Public/sidebar" menu='zhgl.cszh'/>
    <div class="mianR">
        <h3 class="yonghu">编辑车商</h3>
        <h4 class="number-text">车商基本信息</h4>
        <div class="new-dealer">
            <form id="dealerForm">
                <input type="hidden" name="dealer_id" value="{$dealer.dealer_id}">
                <table class="table">
                    <tbody>
                    <tr>
                        <td width="15%">用户名</td>
                        <td>{$dealer.user_name}</td>
                    </tr>
                    <if condition="$dealer.level eq 0">
                        <tr>
                            <td>车商等级</td>
                            <td>{$dealer.level_name}</td>
                        </tr>
                    </if>
                    <if condition="$dealer.auth_type gt 0">
                        <tr>
                            <td width="15%">头像</td>
                            <td><img src="{:get_content_cdnurl()}{$dealer.avatar}"
                                     _src="{:get_style_cdnurl()}paimai/yunying/images/carded_ico.jpg"
                                     class="portrait-ico"></td>
                        </tr>
                    </if>
                    <if condition="$dealer.auth_type eq 1">
                        <tr>
                            <td>姓名</td>
                            <td>{$dealer.real_name}</td>
                        </tr>
                        <tr>
                            <td>身份证号</td>
                            <td>{$dealer.dealer_idcard}</td>
                        </tr>
                        <tr>
                            <td>身份证正面</td>
                            <td><img src="{:get_content_cdnurl()}{$dealer.idcard_front_pic}"
                                     _src="{:get_style_cdnurl()}paimai/yunying/images/carded_pic_bg.jpg"></td>
                        </tr>
                        <tr>
                            <td>身份证背面</td>
                            <td><img src="{:get_content_cdnurl()}{$dealer.idcard_back_pic}"
                                     _src="{:get_style_cdnurl()}paimai/yunying/images/carded_pic_bg.jpg"></td>
                        </tr>
                        <tr>
                            <td width="15%">手持身份证</td>
                            <td><img src="{:get_content_cdnurl()}{$dealer.idcard_hold_pic}"
                                     _src="{:get_style_cdnurl()}paimai/yunying/images/carded_pic_bg.jpg"></td>
                        </tr>
                        <tr>
                            <td>通讯地址</td>
                            <td>{$dealer.address}</td>
                        </tr>
                    </if>

                    <if condition="$dealer.auth_type eq 2">
                        <tr>
                            <td>公司名称</td>
                            <td>{$dealer.fullname}</td>
                        </tr>
                        <tr>
                            <td>营业执照号</td>
                            <td>{$dealer.business_license_num}</td>
                        </tr>
                        <tr>
                            <td>营业执照照片</td>
                            <td><img src="{$dealer.business_license_pic}"
                                     _src="{:get_style_cdnurl()}paimai/yunying/images/carded_pic_bg.jpg"></td>
                        </tr>
                        <tr>
                            <td width="15%">是否三证合一</td>
                            <td>{$dealer.three_in_one}</td>
                        </tr>
                        <if condition="$dealer.is_three_in_one neq 1">
                            <tr>
                                <td>组织机构代码证号码</td>
                                <td>{$dealer.organization_code}</td>
                            </tr>
                            <tr>
                                <td>组织机构代码证照片</td>
                                <td><img src="{$dealer.organization_code_pic}"
                                         _src="{:get_style_cdnurl()}paimai/yunying/images/carded_pic_bg.jpg"></td>
                            </tr>
                            <tr>
                                <td>税务登记证号</td>
                                <td>{$dealer.tax_reg_cert_no}</td>
                            </tr>
                            <tr>
                                <td>税务登记证照片</td>
                                <td><img src="{$detail.tax_reg_cert_pic}"
                                         _src="{:get_style_cdnurl()}paimai/yunying/images/carded_pic_bg.jpg"></td>
                            </tr>
                        </if>
                        <tr>
                            <td width="15%">授权人姓名</td>
                            <td>{$dealer.contact_person}</td>
                        </tr>
                        <tr>
                            <td width="15%">授权人身份证</td>
                            <td>{$dealer.dealer_idcard}</td>
                        </tr>
                        <tr>
                            <td width="15%">授权人身份证正面</td>
                            <td><img src="{$dealer.idcard_front_pic}"
                                     _src="{:get_style_cdnurl()}paimai/yunying/images/carded_pic_bg.jpg"></td>
                        </tr>
                        <tr>
                            <td width="15%">授权人身份证背面</td>
                            <td><img src="{$dealer.idcard_back_pic}"
                                     _src="{:get_style_cdnurl()}paimai/yunying/images/carded_pic_bg.jpg"></td>
                        </tr>
                        <tr>
                            <td width="15%">授权人手持身份证照</td>
                            <td><img src="{$dealer.idcard_hold_pic}"
                                     _src="{:get_style_cdnurl()}paimai/yunying/images/carded_pic_bg.jpg"></td>
                        </tr>
                        <tr>
                            <td width="15%">授权委托书</td>
                            <td><img src="{$dealer.auth_letter_pic}"
                                     _src="{:get_style_cdnurl()}paimai/yunying/images/carded_pic_bg.jpg"></td>
                        </tr>
                        <tr>
                            <td width="15%">通讯地址</td>
                            <td>{$dealer.address}</td>
                        </tr>
                    </if>

                    <if condition="$dealer.auth_type eq 1 gt 0">
                        <tr>
                            <td width="15%">车商类型</td>
                            <td>{$dealer.auth_type_name}</td>
                        </tr>
                    </if>

                    <tr>
                        <td>
                            <if condition="$dealer.auth_type gt 1">
                                授权人手机号
                                <else/>
                                手机号
                            </if>
                        </td>
                        <td>
                            <input id="dealer_phone" name='dealer_phone' type="text" value="{$dealer.mobile}"
                                   placeholder="请输入手机号">

                        </td>
                    </tr>
                    <tr>
                        <td>经营城市</td>
                        <td>
                            <select id="business_city" name="business_city" class="citySelect">
                                <option value="0">请选择车商经营城市</option>
                                <volist name="city_list" id="cl">
                                    <option value="{$cl.code}" bc-id="{$cl.branch_id}"
                                    <?php if ($cl['code'] == $dealer['business_city']): ?>
                                    selected = "selected"
                                    <?php endif ?>
                                    >{$cl.name}</option>
                                </volist>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td>客户经理</td>
                        <td>
                            <select id="branch_company" name="branch_company" class="managerSelect">
                                <option value="-1">请选择分公司</option>
                                <option value="0">总部</option>
                                <?php foreach($branch_list as $bk=>$branch):?>
                                <option value="{$branch.id}">{$branch.name}</option>
                                <?php endforeach;?>
                            </select>
                            <script>$("#branch_company").val("{$branch_id}");</script>
                            <select id="man_id" name="manager_id" class="managerSelect">
                                <option value="0">请选择客户经理</option>
                            </select>
                        </td>
                    </tr>
                    <if condition="$dealer.auth_type gt 0">
                        <tr>
                            <td width="15%">车商等级</td>
                            <td>
                                <select id="dealer_level" name="dealer_level" class="citySelect">
                                    <option>请选择车商等级</option>
                                    <volist name="DEALER_LEVEL" id="dl" key="k">
                                        <option value="{$k}"
                                        <?php if ($k == $dealer['level']): ?>
                                        selected = "selected"
                                        <?php endif ?>
                                        >{$dl}</option>
                                    </volist>
                                </select>
                            </td>
                        </tr>
                    </if>
                    </tbody>
                </table>
            </form>
        </div>

        <div id="showOption" style="display:none">
            <?php foreach($man_list as $vo):?>
                <option class="{$vo['branch_id']}" value="{$vo['emp_id']}"
                <if condition="$vo['emp_id'] eq $dealer['manager_id']">selected="selected"
                    <else/>
                </if>
                >{$vo['real_name']}</option>
            <?php endforeach;?>
        </div>

        <div class="yongBtn">
            <input type="button" value="确定" class="queding"/>
            <input name="cancel" type="button" class="quxiao" onclick="history.go(-1);" value="取消"/>
        </div>
    </div>
    <div class="clear"></div>
</div>
<!--弹出框效果-->
<div class="sunbox-alret">
    <img src=""/>

</div>
<div class="fork"></div>
<div class="xuanzhuan"></div>
<div class="xie-loading"></div>
<div class="pageBeijing"></div>
<script type="text/javascript" src="http://img4.isou365.cn/paimai/yunying/js/jquery.rotate.min.js"></script>
<script style="text/javascript">
    $(function () {
        init();
        //城市所属的分公司
//        $("#business_city").change(function () {
//            var bc_id = $(this).find('option:selected').attr('bc-id');
//            $("#man_id option").each(function () {
//                if ($(this).val() != '0') {
//                    $(this).remove();
//                }
//            });
//            var branch_company_obj = $("#branch_company option");
//            branch_company_obj.each(function (i, data) {
//                var branch_id = $(this).val();
//                if (bc_id == branch_id) {
//                    $(this).prop('selected', 'selected');
//                    //显示具体渠道下拉列表
//                    $("#man_id").empty()
//                            .append('<option value="0" >请选择客户经理</option>')
//                            .append($("#showOption ." + bc_id).clone());
//                } else {
//                    $(this).prop('selected', false);
//                }
//            })
//        });
        //分公司下的客户经理
        $("#branch_company").change(function () {
            var value = $(this).val(); //获取渠道当前下拉列表选中的值
            //隐藏所有下拉列表的值
            $("#man_id option").each(function () {
                if ($(this).val() != '0') {
                    $(this).remove();
                }
            });
            //显示具体渠道下拉列表
            $("#man_id").empty()
                    .append('<option value="0" >请选择客户经理</option>')
                    .append($("#showOption ." + value).clone());
        });
        //初始化分公司客户经理列表
        function init() {
            var branch_obj = $('#branch_company');
            var branch_id = branch_obj.val();
            var optstr = '';
            $('#showOption option').each(function () {
                var class_id = $(this).attr('class');
                var value = $(this).val();
                var text = $(this).html();
                if (value == "<?php echo $dealer['manager_id']>0 ? $dealer['manager_id'] : 0 ;?>") {
                    optstr += "<option value='" + value + "' selected='selected' >" + text + "</option>"
                } else if (class_id == branch_id) {
                    optstr += "<option value='" + value + "'>" + text + "</option>"
                }
            });
            optstr = "<option value='0'>请选择客户经理</option>" + optstr;
            //显示具体渠道下拉列表
            $("#man_id").empty().append(optstr);
        }

        $(".new-dealer .table img").each(function () {
            var srcImg = $(this).attr("_src");
            if ($(this).attr("src") == "") {
                $(this).attr("src", srcImg);
            }
            $(this).click(function () {
                if ($(this).attr("src") == srcImg) {
                    return false;
                }
                var Img = $(this).attr("src").split("@");
                $(".xuanzhuan").fadeIn();
                $(".fork").fadeIn();
                $(".pageBeijing").css("display", "block");
                $(".xie-loading").fadeIn();
                $(".sunbox-alret img").attr("src", Img[0]).get(0).onload = function () {
                    $(".sunbox-alret").fadeIn();
                    $(".sunbox-alret").rotate(0);
                    $(".xie-loading").fadeOut();
                    $(".sunbox-alret").css("top", $(window).scrollTop());
                    $(".sunbox-alret").css({
                        "marginTop": 100,
                        "marginLeft": -$(".sunbox-alret").outerWidth() / 2
                    });
                };
            });
        });
        var num = 0;
        $(function () {
            $(".xuanzhuan").click(function () {
                num++;
                $(".sunbox-alret").rotate(90 * num);
            });
        });

        $(".fork").click(function () {
            $(".pageBeijing").css("display", "none");
            $(".sunbox-alret").fadeOut();
            $(".xuanzhuan").fadeOut();
            $(".fork").fadeOut();
            $(".xie-loading").fadeOut();
            $(".sunbox-alret img").attr("src", "");
            num = 0;
        });

        $(".queding").click(function () {
            var post_data = "";
            post_data = $("#dealerForm").serialize();
            var btn_obj = $(this);
            btn_obj.val("提交中...").attr("disabled", 'disabled');
            $.post("/CarDealer/saveEdit", post_data, function (data) {
                if (data.code != 200) {
                    shibai_alert(data.msg, 1500);
                    btn_obj.val("确定").removeAttr("disabled style");
                    return false;
                }
                btn_alert("更新成功", 1500, function () {
                    location.href = "/CarDealer/user_list?p={$p}";
                });
            }, "json");
        });

    });
</script>
<include file="Public/foot"/>
